<template>
	<div>
		<div>
			<db></db>
		</div>
  
		<div>
			<div v-if="xsyc">
			
				<!-- <van-cell is-link title="退出登录" @click="tc" /> -->
				<dlcg :key="jiajia" @fb="fb" @xgmm="xgmm" @tc="tc"></dlcg>
				<!-- <van-cell is-link title="修改密码" @click="xgmm" />
                <van-cell is-link title="我的发布" @click="$router.push('wdefb')" /> -->
			</div>
			<div v-else>
				<!-- <div>没有登录显示</div>
				<router-link to="/dlu">您还没有登录，请登录</router-link> -->
			</div>
			


		</div>
	</div>
</template>

<script>
import {mapState} from 'vuex'
	import db from '../../components/dibu/db.vue'
	import dlcg from '@/components/dlzj/dlcg.vue'
	import { Dialog } from 'vant'
	export default {
		components: {
			db,
			dlcg 
		},
		data() {
			return {
				//  xs:false,         //没有全局之前
				//  userInfo:{}
				jiajia:0
			}
		},
		created() {
			// let {uid,token,tokenExpired,userInfo}=localStorage;
			// console.log(uid,token,tokenExpired,userInfo.name)
			// if(uid&&userInfo){
			//        this.xs=true;
			//        this.userInfo=JSON.parse(userInfo)
			// }else{
			//   this.xs=false
			// }
     
		},
    computed:{
  ...mapState('mkhuser',['xsyc','userInfo']),


   
    },
	watch:{
		xsyc:{
			immediate: true,
      handler(val) {
		console.log(val)
		if(val==false){
          this.$router.push('dlu')
		}
	  }

		}
	},
	mounted(){
     console.log(this.userInfo)
	 if(this.yc=false){
         this.$router.push('dlu')
	 }
	 this.$bus.$on('bh',()=>{
		console.log(123)
                 this.jiajia++
			})
	},
	methods: {
			tc() {
				Dialog.confirm({
        message: '您确定要退出登录吗？',
      })
        .then(() => {

			localStorage.clear();
				// this.$root.userInfo = {};
				// this.$root.xsyc = false;
           this.$store.commit('mkhuser/TCDL')
		// this.store.mkhuser.cpmmit('TCDL')
         setTimeout(()=>{
          this.$toast('退出成功')
		 },500)
        })
        .catch(() => {
          // on cancel
        });	
			},
                 xgmm(){
					this.$router.push('xgmm')
				 },
				 fb(){
					this.$router.push('wdefb')
				 }
    
		}
	}
</script>

<style>

</style>
